﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Threading;

namespace Client
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Parse the command line args into a dictionary so that it can be used by the program
            Dictionary<string, string> cmdArgs = new Dictionary<string, string>();

            for (int i = 1; i < e.Args.Length; i += 2)
            {
                string argName = e.Args[i - 1];
                if (!cmdArgs.ContainsKey(argName))
                {
                    cmdArgs.Add(argName, e.Args[i]);
                }               
            }

            this.Properties["CommandLineArgs"] = cmdArgs;
        }

        private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show("ERROR!!  " + e.Exception);

            e.Handled = true;
        }
    }
}
